package com.work.sys.controller;


import com.work.common.annotation.PassToken;
import com.work.common.core.controller.BaseController;
import com.work.common.core.domain.AjaxResult;
import com.work.mp.service.impl.MpTokenService;
import com.work.sys.service.ISysRoleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 注册登录Controller
 *
 * @author lee
 * @date 2021-04-18
 */
@RestController
@RequestMapping("/api/sys/role")
@Api(tags = {"用户权限接口"}, value = "用户权限")
public class SysRoleController extends BaseController {

    @Autowired
    private ISysRoleService sysRoleService;
    @Autowired
    private MpTokenService tokenService;

    @GetMapping("/getRole")
    @PassToken
    @ApiOperation(value = "获取用户权限", notes = "获取用户权限接口")
    public AjaxResult getRole(
            @ApiParam(value = "用户token", required = true)
            @RequestHeader("tk")
                    String tk) {
        return AjaxResult.success(sysRoleService.selectRoleListByUserId(tokenService.getUserId(tk)));
    }
}
